package com.ebs.md.fxmonitor.marketmonitor.config;

/**
 * Revision Author:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/config/PassiveHitsBTSConfigImpl.java $
 *  $Revision: #2 $
 *  $DateTime: 2012/10/18 16:25:34 $
 *  $Change: 115985 $
 *  $Author: Aviad.Yosef $
 */

import org.apache.log4j.Logger;

import com.ebs.md.fxmonitor.marketmonitor.MarketMonitorConsts;
import com.ebsdr.fsp.ccc.configuration.IConfiguration;

public class PassiveHitsBTSConfigImpl implements IPassiveHitsBTSConfig, IConfigListener, MarketMonitorConsts
{
    final protected Logger logger = Logger.getLogger(getClass());
    final protected static String xsdPath = "/MonitoredMarketActivity/PassiveHitsBTS/PassiveHitBTS";

    private int  numberOfHitsThreshold;
	private long timeFrameThreshold;
	private long unavailablePriceTimeThreshold;

	
	@Override
	public String getName() {
		return BASIC_CONFIG_NAME;
	}

	@Override
	public void onConfig(IConfiguration configuration) 
	{
	    numberOfHitsThreshold         = configuration.getInt (xsdPath + "/@numberOfHits", EVENT_PASSIVE_HITS_BTS_NUMBER_OF_HITS_THRESHOLD);
		timeFrameThreshold            = configuration.getLong(xsdPath + "/@timeFrame",    EVENT_PASSIVE_HITS_BTS_TIME_FRAME_THRESHOLD);
		unavailablePriceTimeThreshold = configuration.getLong(xsdPath + "/@reactionTime", EVENT_PASSIVE_HITS_BTS_UNAVAILABLE_PRICE_TIME_FRAME_THRESHOLD);
		
		logger.info( getConfigInfo() );
	}

	@Override
	public String getConfigInfo() {
		StringBuilder sb = new StringBuilder("PassiveHitsBTSConfigImpl: ");
		
		sb.append( " numberOfHits: " + numberOfHitsThreshold);
		sb.append(", timeFrame: "    + timeFrameThreshold);
		sb.append(", reactionTime: " + unavailablePriceTimeThreshold);
		
		return sb.toString();
	}
	
	@Override
	public int getNumberOfHitsThreshold() {
		return numberOfHitsThreshold;
	}

	@Override
	public long getTimeFrameThreshold() {
		return timeFrameThreshold;
	}

	@Override
	public long getUnavailablePriceTimeThreshold() {
		return unavailablePriceTimeThreshold;
	}

}
